namespace ZFramework.Runtime
{
    /// <summary>
    /// 显示实体失败事件。
    /// </summary>
    public sealed class ShowItemFailureEventArgs : GameEventArgs
    {
        public static int EventId = typeof(ShowItemFailureEventArgs).GetHashCode();

        /// <summary>
        /// 初始化显示实体失败事件的新实例。
        /// </summary>
        public ShowItemFailureEventArgs()
        {
            ItemId = 0;
            ItemAssetName = null;
            ItemGroupName = null;
            ErrorMessage = null;
            UserData = null;
        }

        /// <summary>
        /// 获取实体编号。
        /// </summary>
        public int ItemId { get; private set; }

        /// <summary>
        /// 获取实体资源名称。
        /// </summary>
        public string ItemAssetName { get; private set; }

        /// <summary>
        /// 获取实体组名称。
        /// </summary>
        public string ItemGroupName { get; private set; }

        /// <summary>
        /// 获取错误信息。
        /// </summary>
        public string ErrorMessage { get; private set; }

        /// <summary>
        /// 获取用户自定义数据。
        /// </summary>
        public object UserData { get; private set; }

        /// <summary>
        /// 创建显示实体失败事件。
        /// </summary>
        /// <param name="itemId">实体编号。</param>
        /// <param name="itemAssetName">实体资源名称。</param>
        /// <param name="itemGroupName">实体组名称。</param>
        /// <param name="errorMessage">错误信息。</param>
        /// <param name="userData">用户自定义数据。</param>
        /// <returns>创建的显示实体失败事件。</returns>
        public static ShowItemFailureEventArgs Create(int itemId, string itemAssetName, string itemGroupName,
            string errorMessage, object userData)
        {
            ShowItemFailureEventArgs showEntityFailureEventArgs = ReferencePool.Acquire<ShowItemFailureEventArgs>();
            showEntityFailureEventArgs.ItemId = itemId;
            showEntityFailureEventArgs.ItemAssetName = itemAssetName;
            showEntityFailureEventArgs.ItemGroupName = itemGroupName;
            showEntityFailureEventArgs.ErrorMessage = errorMessage;
            showEntityFailureEventArgs.UserData = userData;
            return showEntityFailureEventArgs;
        }

        public override int Id
        {
            get { return EventId; }
        }

        /// <summary>
        /// 清理显示实体失败事件。
        /// </summary>
        public override void Clear()
        {
            ItemId = 0;
            ItemAssetName = null;
            ItemGroupName = null;
            ErrorMessage = null;
            UserData = null;
        }
    }
}
